Restrict permissions on disk token cache - #866
Open
hadley wants to merge 2 commits into
Open
Conversation
The OAuth disk cache directory was created with default permissions (typically 755) and token files were written with the default 644, so cached tokens were readable by other users on the same machine. Now create the cache directory with mode `0700` (and re-apply it to directories created by earlier versions) and chmod token files to `0600` after writing.
Move `skip_on_os("windows")` after the set/get round-trip so that the
`Sys.chmod()` calls are exercised on Windows too; only the mode
assertions are skipped there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The on-disk OAuth token cache was created with default permissions: directories at 755 and token files at 644 (subject to umask), so cached tokens were readable by other local users. Since the "encryption" of these files uses a key shipped inside the package, file permissions are the real line of defense on multi-user machines.
This PR:
0700, and re-applies that mode on each use so directories created by earlier versions of httr2 are also fixed up.0600after writing, matching the hardeningsecret_decrypt_file()already applies.Both changes are no-ops on Windows, where these modes don't apply; the new test is skipped there.
🤖 Generated with Claude Code